package com.enation.app.javashop.api.client;

import com.enation.app.javashop.client.promotion.FullDiscountGiftClient;
import com.enation.app.javashop.model.goods.enums.QuantityType;
import com.enation.app.javashop.model.promotion.fulldiscount.dos.FullDiscountGiftDO;
import com.enation.app.javashop.service.promotion.fulldiscount.FullDiscountGiftManager;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import springfox.documentation.annotations.ApiIgnore;

import java.util.List;

/**
 * @author fk
 * @version v2.0
 * @Description: 满送赠品client
 * @date 2020/4/3 11:21
 * @since v7.2.0
 */
@Api(description = "优惠券相关API")
@RestController
@RequestMapping("/client/promotion/full-discount-gift")
@Validated
@ApiIgnore
public class FullDiscountGiftClientController {

    @Autowired
    private FullDiscountGiftManager fullDiscountGiftManager;

    @RequestMapping(value = "/quantity/add", method = RequestMethod.POST)
    public boolean addGiftQuantity(@RequestBody List<FullDiscountGiftDO> giftDOList) {
        return fullDiscountGiftManager.addGiftQuantity(giftDOList);
    }

    @RequestMapping(value = "/quantity/reduce", method = RequestMethod.POST)
    public boolean reduceGiftQuantity(@RequestBody List<FullDiscountGiftDO> giftDOList, @RequestParam("type") QuantityType type) {
        return fullDiscountGiftManager.reduceGiftQuantity(giftDOList, type);
    }

    @RequestMapping(value = "/enable-quantity/add", method = RequestMethod.POST)
    public boolean addGiftEnableQuantity(@RequestBody List<FullDiscountGiftDO> giftDOList) {
        return fullDiscountGiftManager.addGiftEnableQuantity(giftDOList);
    }

    @RequestMapping(value = "/{id}", method = RequestMethod.GET)
    public FullDiscountGiftDO getModel(@PathVariable("id") Long id) {
        return fullDiscountGiftManager.getModel(id);
    }
}
